<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<html>
    <head>
        <title>评价页面</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
         <!--标准mui.css-->
         <link rel="stylesheet" href="/Public/Css/css/mui.min.css">
         <script src="/Public/js/mui.min.js"></script>
          <!--标准muiEND-->
        <link rel="stylesheet" href="/Public/weui/style/weui.min.css"/>
        <style>
            body{
                background-color:#fff;
            }
            .evaluate-box{
                padding:15px;
            }
            .evaluate-star{
                width:260px;
                margin:100px auto 50px;
            }
            .evaluate-star .star-item{
                margin-bottom:20px;
                display:flex;
            }
            .evaluate-star .star-item .label{
                font-size:16px;
                color:#333;
                max-width:100px;
                width:90px;
            }
            .evaluate-star .star-item .star-list{
                flex:1;
                min-width:0;
            }
            .evaluate-star .star-item .star-list .item{
                display:inline-block;
                margin-right:5px;
                width:20px;
                height:20px;
                background:url('') no-repeat center center;
                background-size:cover;
            }
            .evaluate-star .star-item .star-list .item.active{
                background:url('') no-repeat center center;
                background-size:cover;
            }
            .evaluate-text{
                display:block;
                width:300px;
                margin:0 auto;
                height:150px;
                resize:none;
                padding:8px;
                font-size:13px;
                color:#333;
                margin-bottom:30px;
                border-radius:4px;
            }
            .evaluate-text:focus{
                border-color:#04be02;
            }
        </style>
    </head>
    <body>
        <div class="evaluate-box">
            <div class="evaluate-star">
                <div class="star-item">
                    <div class="label">服务评分：</div>
                    <div class="star-list js_service_star" data-star="0">
                        <span class="item"></span>
                        <span class="item"></span>
                        <span class="item"></span>
                        <span class="item"></span>
                        <span class="item"></span>
                    </div>
                </div>
                <div class="star-item">
                    <div class="label">司机评分：</div>
                    <div class="star-list js_driver_star" data-star="0">
                        <span class="item"></span>
                        <span class="item"></span>
                        <span class="item"></span>
                        <span class="item"></span>
                        <span class="item"></span>
                    </div>
                </div>
                <div class="star-item">
                    <div class="label">车辆评分：</div>
                    <div class="star-list js_car_star" data-star="0">
                        <span class="item"></span>
                        <span class="item"></span>
                        <span class="item"></span>
                        <span class="item"></span>
                        <span class="item"></span>
                    </div>
                </div>
            </div>

            <textarea style="-webkit-user-select: auto!important;" contenteditable="true" class="evaluate-text js_evaluate_txt" placeholder="请填写您对司机的评价(选填)"></textarea>

            <a href="javascript:;" class="weui_btn weui_btn_primary js_form_submit">
                提交评价
            </a>
        </div>
        <script src="//libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
        <script>
            $(function(){

                var stars = $(".js_service_star,.js_driver_star,.js_car_star");
                var submit = $(".js_form_submit");

                stars.on('click','.item',function(e){
                    var $this = $(this);
                    var index = $this.index();
                    var parent = $this.parent();
                    $this.removeClass('active').siblings().removeClass('active');
                    for(var i = 0; i <= index; i++){
                        parent.children().eq(i).addClass('active');
                    }
                    parent.attr('data-star',index+1);
                })

                submit.on('click',function(){
                    var service = $(".js_service_star").attr('data-star');
                    var driver = $(".js_driver_star").attr('data-star');
                    var car = $(".js_car_star").attr('data-star');
                    var txt = $(".js_evaluate_txt").val();
                    var orderid = '<?php echo ($orderid); ?>';

                    if(service <= '0'){
                        alert('请对司机的服务评分！');
                        return;
                    }

                    console.log(orderid);
                    if(!orderid){
                        alert('订单信息不存在，评价失败！');
                        return;
                    }
                    $.ajax({
                        type: "post",
                        url: "/index.php/Evaluate/createEvaluate",
                        data: {servicescore: service, driverscore: driver,vehiclescore:car,detail: txt,orderid: orderid},
                        dataType: "json",
                        success: function (data) {
                            if(data.code == 1){
                                window.location.href = document.referrer;
                            }
                        }
                    });


                })
            })

            function getQueryString(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
                var reg_rewrite = new RegExp("(^|/)" + name + "/([^/]*)(/|$)", "i");
                var r = window.location.search.substr(1).match(reg);
                var q = window.location.pathname.substr(1).match(reg_rewrite);
                if(r != null){
                    return unescape(r[2]);
                }else if(q != null){
                    return unescape(q[2]);
                }else{
                    return null;
                }
            }
        </script>

    </body>
</html>